using UnityEngine;

[ExecuteInEditMode]
public class ControllerCheckPointSpawn : ControllerGeneric
{
	public RemoteControl platformRC;

	private void Update()
	{
		if (!Application.isEditor || Application.isPlaying)
		{
			return;
		}
		if (platformRC == null)
		{
			Object.DestroyImmediate(base.gameObject);
			return;
		}
		SetupRemoteControl();
		if (IsRemoteControlActive())
		{
			base.transform.position = remoteControl.transform.position;
			base.transform.rotation = remoteControl.transform.rotation;
		}
		if (remoteControl != null)
		{
			remoteControl.transform.localScale = Vector3.one;
			remoteControl.scale = Vector3.one;
		}
		Setup();
	}

	private void Setup()
	{
		AssureParenting();
	}

	public void SetupRemoteControl()
	{
		if (remoteControl == null)
		{
			InitRemoteControl();
			remoteControl.gameObject.name = remoteControl.gameObject.name + base.name;
			remoteControl.gameObject.transform.position = base.transform.position;
			remoteControl.gameObject.transform.rotation = base.transform.rotation;
			remoteControl.gameObject.transform.localScale = Vector3.one;
			remoteControl.destroyable = false;
			remoteControl.duplicable = false;
		}
	}
}
